#pragma once

#include "DiolObject.h"

namespace Diol
{

/*
	POV

	The POV (Point-of-View, aka "Hat switch") object represents a small 
	bidimensional axis indicating a direction. 
	
	At rest, it is mechanically centered. In that case, the method isCentered() 
	returns true. It's not valid to call getAngle(). It will complain 
	in debug and return 0.
	
	If the user moves the stick, isCentered() returns false and getAngle() 
	returns the angle of the stick multiplied by a factor of 100.

	The angle goes clockwise from 0 indicating north, 45000 for north-east, 
	90000 for east, all the way to 31500 for north-west. 

	Note that as far as I've seen, most POV are digital and only provide 
	discrete (45 degrees-spaced) values.
*/
class POV : public Object
{
public:
	POV( const ObjectInstance& objectInstance, Device* parentDevice );

	// Indicate whether the POV stick is centered. In this rest position,
	// the stick doesn't indicate any angle (by default getAngle returns 0)
	bool				isCentered() const				{ return mIsCentered; }
	
	// The angle of the POV stick returned in hundredth-of-degree units (9000 means 90 degrees).
	// It is expressed clockwise with 0 being "north" (i.e forward)
	DWORD				getAngle() const;
	
	virtual std::string	toString() const;
	virtual void		updateFrom( const DIDEVICEOBJECTDATA& entry );

protected:
	void				setValue( bool isCentered, DWORD value );
	
private:
	bool				mIsCentered;
	DWORD				mAngle;
};

}
